package com.jmemoir.base.event.service.impl;

import com.jmemoir.base.common.dto.Result;
import com.jmemoir.base.event.dto.UserRegisterDTO;
import com.jmemoir.base.event.service.UserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

/**
 * 用户接口-实现类
 *
 * @author Tellsea
 * @date 2023/8/3
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class UserServiceImpl implements UserService {

    private final ApplicationContext applicationContext;

    @Override
    public Result<String> register(UserRegisterDTO userRegisterDTO) {
        // 用户注册
        log.info("用户注册成功：{}", userRegisterDTO.getUserName());
        // 推送消息
        applicationContext.publishEvent(userRegisterDTO);
        return Result.success("注册成功");
    }
}
